Fix clickable links in canvas previews - #136
Open
Luna Qiu (lunaqiu) wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Links in drag-only previews can still initiate node dragging and cannot be activated with Enter.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates Milkdown previews so links open normally in read-only canvas surfaces while retaining modifier-click behavior in editable editors.
Changes:
- Enables plain-click link activation in read-only and drag-only previews.
- Restores pointer events for links inside note previews.
- Adds regression tests and updates architecture documentation.
File summaries
| File | Description |
|---|---|
docs/architecture/note-node.md |
Documents link behavior by surface mode. |
MilkdownPreview.tsx |
Restores link pointer interaction. |
createMilkdown.ts |
Selects plain- or modifier-click behavior. |
previewAccessibility.test.tsx |
Tests link hit-testing classes. |
blockCommands.test.ts |
Tests link activation modes. |
Review details
Suppressed comments (1)
apps/web/src/components/Milkdown/MilkdownPreview.tsx:269
- In
enableBlockDragpreviews these links remain mouse-only:onKeyDownCapturetreats Enter as an editing key and callspreventDefault, so a focused anchor cannot perform its native keyboard activation. Exempt Enter when the event target is ana[href](while continuing to swallow Enter elsewhere) and cover the drag-only component path with a keyboard test.
className={clsx('[&_a]:pointer-events-auto', className)}
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <div | ||
| ref={containerRef} | ||
| className={className} | ||
| className={clsx('[&_a]:pointer-events-auto', className)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ctrl/Cmd + clickfor editable surfaces while preserving unsafe URL validationFixes #135
Testing
pnpm typecheckpnpm formatpnpm lint:fix(0 errors)pnpm --filter @huabu/web test -- src/components/Milkdown/__tests__/previewAccessibility.test.tsx src/components/Milkdown/__tests__/blockCommands.test.ts(67 passed)